import { request } from "@/request";
import { replacePage } from "@/const";

export async function fetchList(params) {
  const res = await request("/api/code/vacation", {
    params: replacePage(params),
  });
  return new Promise((resolve, reject) => {
    if (res.code === 0) {
      res.data &&
        resolve({
          success: true,
          data: res.data.list,
          current: res.data.page,
          pageSize: res.data.pageSize,
          total: res.data.totalCount,
        });
    } else {
      resolve({
        success: true,
        data: [],
        current: params.current,
        pageSize: params.pageSize,
        total: 0,
      });
    }
  });
}
export async function add(data) {
  return request("/api/code/vacation", {
    method: "POST",
    data,
  });
}
export async function update(data) {
  return request(`/api/code/vacation`, {
    method: "PUT",
    data,
  });
}
export async function remove(data) {
  return request("/api/code/vacation", {
    method: "delete",
    data,
  });
}
